<template>
  <div class="ranking-list">
    <ul class="ranking-head">
      <li
        v-for="(item, index) in head"
        :key="item.id"
        :style="{ width: headWidth[index] }"
      >
        {{ item.text }}
      </li>
    </ul>
    <ul class="ul-list">
      <li v-for="(item, index) in list" :key="item.id">
        <div class="item-ranking" :style="{ width: headWidth[0]}">
          {{ index>2?index+1 : '' }}
        </div>
        <div class="item-area" :style="{ width: headWidth[1] }">
          {{ item.province }}
        </div>
        <div class="item-proportion" :style="{ width: headWidth[2] }">
          <span class="proportion-bg" :style="{width:((item.count/list[0].count)*100)+'%'}">{{ item.rate.toFixed(2) }}%</span>
        </div>
        <div class="item-number" :style="{ width: headWidth[3] }">
          {{ item.count }}
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "rankingList",
  props: {
    head: {
      type: Array,
      default() {
        return [
          {
            id: 0,
            text: "排名",
          },
          {
            id: 1,
            text: "地区",
          },
          {
            id: 2,
            text: "占比",
          },
          {
            id: 3,
            text: "覆盖数",
          },
        ];
      },
    },
    headWidth: {
      type: Array,
      default() {
        return ["15%", "15%", "55%", "15%"];
      },
    },
    list: {
      type: Array,
      default() {
        return []
      },
    },
  },
  mounted () {
  }
};
</script>

<style lang="scss" scoped>
.ranking-list {
    height: calc(100% - 20px);
    
  .ranking-head {
    position: relative;
    display: flex;
    width: 100%;
    margin-top: 10px;
    padding: 0 5px;
    color: #00d1d2;
    font-size: 14px;
    &::after {
      content: " ";
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 1px;
      background: linear-gradient(to right, #081e40, #00fbfc 49%,#00fbfc 62%, #081e40 100%);
    }
    &::before {
      content: " ";
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 1px;
      background: linear-gradient(to right, #081e40, #00fbfc 49%,#00fbfc 62%, #081e40 100%);
    }
    li {
      text-align: center;
      height: 28px;
      line-height: 28px;
    }
  }
  .ul-list::-webkit-scrollbar{
    display: none;
  }
  .ul-list {
      margin-top: 10px;
      height: calc(100% - 30px);
      overflow-y: scroll;
      scrollbar-width: none;
    li{
      display: flex;
      text-align: center;
      height: calc(100% / 10);
      align-items: center;
      margin-bottom: 5px;
      .item-ranking {
        font-size: 16px;
        font-family: MicrosoftYaHei-Bold;
        color: #06a4b1;
        background-repeat: no-repeat;
        background-size: 33px 24px;
        background-position: center;

      }
      .item-area {
        color: #ffffff;
        font-family: MicrosoftYaHei;
        font-size: 14px;
      }
      .item-proportion {
          text-align: left;
            margin-top: -5px;
          .proportion-bg{
              text-align: center;
              display: inline-block;
              height: 12px;
              line-height: 12px;
              font-weight: 600;
              font-size: 12px;
              border-radius:6px;
              font-family: MicrosoftYaHei-Bold;
              color: #081e40;
              background: linear-gradient(to right, transparent, #00fbfc 30%,#00fbfc 90%,#ffffff 100%);
          }
      }
      .item-number {
        color: #fff;
        font-family: MicrosoftYaHei;
        font-size: 14px;
      }
      &:nth-child(1){
          .item-ranking{
              height: 100%;
               background-image: url('../../../assets/data-images/top1.png');
          }
      }
      &:nth-child(2){
          .item-ranking{
              height: 100%;
               background-image: url('../../../assets/data-images/top2.png');
          }
      }
      &:nth-child(3){
          .item-ranking{
              height: 100%;
               background-image: url('../../../assets/data-images/top3.png');
          }
      }
    }
  }
}
</style>